<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;



class IndexController extends Controller
{
    //主页
    public function index()
    {
		//查询公示广告图片
		$data = DB::table('carousel')->select('ad_pic')->where('class',3)->where('disabled','1')->first()->ad_pic;
    	$carousel_ads=DB::table('carousel')->where('class','=','2')->where('disabled','=','1')->orderBy('car_id')->take(3)->get();
    	//var_dump($carousel_ads);
    	$new_products=DB::table('product')->where('disabled','=','1')->orderBy('new_recommended','desc')->orderBy('rtime','desc')->orderBy('product_id','desc')->take(4)->select('product_id','title','keyword','logo_pic')->get();
    	//var_dump($new_products);
    	$hotsell_products=DB::table('product')->where('disabled','=','1')->orderBy('hotsell_recommended','desc')->orderBy('sellnum','desc')->orderBy('chicknum','desc')->orderBy('product_id','desc')->take(8)->select('product_id','title','sprice','logo_pic')->get();
    	//var_dump($hotsell_products);
    	$boutique_products=DB::table('product')->where('disabled','=','1')->where('ad_pic','<>','')->orderBy('boutique_recommended','desc')->orderBy('collectnum','desc')->orderBy('product_id','desc')->take(3)->select('product_id','title','description','ad_pic')->get();
    	//var_dump($boutique_products);
       	return view('/home/main/index',['data'=>$data,'carousel_ads'=>$carousel_ads,'new_products'=>$new_products,'hotsell_products'=>$hotsell_products,'boutique_products'=>$boutique_products]);

    }
}
